package com.esms.utils;

import com.esms.po.DepGrand;
import com.esms.po.Grand;
import com.esms.po.Sevaluation;
import com.esms.po.Xevaluation;
import org.springframework.stereotype.Component;

@Component
public class ScoreDeal {

    public int scoreCatch(int score) {
        switch (score) {
            case 1:
                score = 95;
                break;
            case 2:
                score = 85;
                break;
            case 3:
                score = 75;
                break;
            case 4:
                score = 65;
                break;
            default:
                /**非法数据按最低分计算**/
                score = 0;
                break;

        }
        return score;
    }

    /**同级评价**/
    public String scoreCalculationGrand(Grand grand) {
        /**德**/
        double deSum = scoreCatch(grand.getaTargetscore1()) * 0.3;
        deSum += scoreCatch(grand.getaTargetscore2()) * 0.26;
        deSum += scoreCatch(grand.getaTargetscore3()) * 0.23;
        deSum += scoreCatch(grand.getaTargetscore4()) * 0.21;
        deSum = deSum * 0.22;

        /**能**/
        double neSum = scoreCatch(grand.getaTargetscore5()) * 0.18;
        neSum += scoreCatch(grand.getaTargetscore6()) * 0.17;
        neSum += scoreCatch(grand.getaTargetscore7()) * 0.19;
        neSum += scoreCatch(grand.getaTargetscore8()) * 0.18;
        neSum += scoreCatch(grand.getaTargetscore9()) * 0.14;
        neSum += scoreCatch(grand.getaTargetscore10()) * 0.14;
        neSum = neSum * 0.2;

        /**勤**/
        double qinSum = scoreCatch(grand.getaTargetscore12()) * 0.5;
        qinSum += scoreCatch(grand.getaTargetscore13()) * 0.5;
        qinSum = qinSum * 0.18;

        /**绩**/
        double jiSum = scoreCatch(grand.getaTargetscore14()) * 0.18;
        jiSum += scoreCatch(grand.getaTargetscore15()) * 0.24;
        jiSum += scoreCatch(grand.getaTargetscore16()) * 0.2;
        jiSum += scoreCatch(grand.getaTargetscore17()) * 0.22;
        jiSum += scoreCatch(grand.getaTargetscore18()) * 0.16;
        jiSum = jiSum * 0.22;

        /**廉**/
        double lianSum = scoreCatch(grand.getaTargetscore19()) * 0.64;
        lianSum += scoreCatch(grand.getaTargetscore20()) * 0.36;
        lianSum = lianSum * 0.18;

        double finaldata = deSum + neSum + qinSum + jiSum + lianSum;
        finaldata = finaldata/100;

        String finalSum = String.format("%.2f",finaldata);

        return finalSum;
    }

    /**上级评价**/
    public String scoreCalculationSevaluation(Sevaluation evaluation) {
        /**德**/
        double deSum = scoreCatch(evaluation.getsTargetscore1()) * 0.3;
        deSum += scoreCatch(evaluation.getsTargetscore2()) * 0.26;
        deSum += scoreCatch(evaluation.getsTargetscore3()) * 0.23;
        deSum += scoreCatch(evaluation.getsTargetscore4()) * 0.21;
        deSum = deSum * 0.22;

        /**能**/
        double neSum = scoreCatch(evaluation.getsTargetscore5()) * 0.18;
        neSum += scoreCatch(evaluation.getsTargetscore6()) * 0.17;
        neSum += scoreCatch(evaluation.getsTargetscore7()) * 0.19;
        neSum += scoreCatch(evaluation.getsTargetscore8()) * 0.18;
        neSum += scoreCatch(evaluation.getsTargetscore9()) * 0.14;
        neSum += scoreCatch(evaluation.getsTargetscore10()) * 0.14;
        neSum = neSum * 0.2;

        /**勤**/
        double qinSum = scoreCatch(evaluation.getsTargetscore12()) * 0.5;
        qinSum += scoreCatch(evaluation.getsTargetscore13()) * 0.5;
        qinSum = qinSum * 0.18;

        /**绩**/
        double jiSum = scoreCatch(evaluation.getsTargetscore14()) * 0.18;
        jiSum += scoreCatch(evaluation.getsTargetscore15()) * 0.24;
        jiSum += scoreCatch(evaluation.getsTargetscore16()) * 0.2;
        jiSum += scoreCatch(evaluation.getsTargetscore17()) * 0.22;
        jiSum += scoreCatch(evaluation.getsTargetscore18()) * 0.16;
        jiSum = jiSum * 0.22;

        /**廉**/
        double lianSum = scoreCatch(evaluation.getsTargetscore19()) * 0.64;
        lianSum += scoreCatch(evaluation.getsTargetscore20()) * 0.36;
        lianSum = lianSum * 0.18;

        double finaldata = deSum + neSum + qinSum + jiSum + lianSum;
        finaldata = finaldata/100;

        String finalSum = String.format("%.2f",finaldata);

        return finalSum;
    }

    /**下级评价**/
    public String scoreCalculationXevaluation(Xevaluation xevaluation) {
        /**德**/
        double deSum = scoreCatch(xevaluation.gettTargetscore1()) * 0.3;
        deSum += scoreCatch(xevaluation.gettTargetscore2()) * 0.26;
        deSum += scoreCatch(xevaluation.gettTargetscore3()) * 0.23;
        deSum += scoreCatch(xevaluation.gettTargetscore4()) * 0.21;
        deSum = deSum * 0.22;

        /**能**/
        double neSum = scoreCatch(xevaluation.gettTargetscore5()) * 0.18;
        neSum += scoreCatch(xevaluation.gettTargetscore6()) * 0.17;
        neSum += scoreCatch(xevaluation.gettTargetscore7()) * 0.19;
        neSum += scoreCatch(xevaluation.gettTargetscore8()) * 0.18;
        neSum += scoreCatch(xevaluation.gettTargetscore9()) * 0.14;
        neSum += scoreCatch(xevaluation.gettTargetscore10()) * 0.14;
        neSum = neSum * 0.2;

        /**勤**/
        double qinSum = scoreCatch(xevaluation.gettTargetscore12()) * 0.5;
        qinSum += scoreCatch(xevaluation.gettTargetscore13()) * 0.5;
        qinSum = qinSum * 0.18;

        /**绩**/
        double jiSum = scoreCatch(xevaluation.gettTargetscore14()) * 0.18;
        jiSum += scoreCatch(xevaluation.gettTargetscore15()) * 0.24;
        jiSum += scoreCatch(xevaluation.gettTargetscore16()) * 0.2;
        jiSum += scoreCatch(xevaluation.gettTargetscore17()) * 0.22;
        jiSum += scoreCatch(xevaluation.gettTargetscore18()) * 0.16;
        jiSum = jiSum * 0.22;

        /**廉**/
        double lianSum = scoreCatch(xevaluation.gettTargetscore19()) * 0.64;
        lianSum += scoreCatch(xevaluation.gettTargetscore20()) * 0.36;
        lianSum = lianSum * 0.18;

        double finaldata = deSum + neSum + qinSum + jiSum + lianSum;
        finaldata = finaldata/100;

        String finalSum = String.format("%.2f",finaldata);

        return finalSum;
    }


    /**周纪实评价*/
    public static String scoreCalculationWeekResult(int score) {
        /**下面是动态的：后续可能需要改造**/
        double weekSum = score;
        String finalSum = String.format("%.2f",weekSum);
        return finalSum;
    }

    /**部门工作业绩考核：扣分项*/
    public static String scoreCalculationGzyj(DepGrand depGrandData) {

        int qTargetscore1 = depGrandData.getqTargetscore1();//分数1
        int qTargetscore2 = depGrandData.getqTargetscore2();//分数1
        int qTargetscore3 = depGrandData.getqTargetscore3();//分数1
        int qTargetscore4 = depGrandData.getqTargetscore4();//分数1
        int qTargetscore5 = depGrandData.getqTargetscore5();//分数1

        int qTargetscore6 = depGrandData.getqTargetscore6();//分数1
        int qTargetscore7 = depGrandData.getqTargetscore7();//分数1
        int qTargetscore8 = depGrandData.getqTargetscore8();//分数1
        int qTargetscore9 = depGrandData.getqTargetscore9();//分数1
        int qTargetscore10 = depGrandData.getqTargetscore10();//分数1

        int qTargetscore11 = depGrandData.getqTargetscore11();//分数1
        int qTargetscore12 = depGrandData.getqTargetscore12();//分数1
        int qTargetscore13 = depGrandData.getqTargetscore13();//分数1
        int qTargetscore14 = depGrandData.getqTargetscore14();//分数1
        int qTargetscore15 = depGrandData.getqTargetscore15();//分数1

        int qTargetscore16 = depGrandData.getqTargetscore16();//分数1
        int qTargetscore17 = depGrandData.getqTargetscore17();//分数1
        int qTargetscore18 = depGrandData.getqTargetscore18();//分数1
        int qTargetscore19 = depGrandData.getqTargetscore19();//分数1
        int qTargetscore20 = depGrandData.getqTargetscore20();//分数1

        int qTargetscore21 = depGrandData.getqTargetscore21();//分数1
        int qTargetscore22 = depGrandData.getqTargetscore22();//分数1
        int qTargetscore23 = depGrandData.getqTargetscore23();//分数1
        int qTargetscore24 = depGrandData.getqTargetscore24();//分数1
        int qTargetscore25 = depGrandData.getqTargetscore25();//分数1

        int totalScore = qTargetscore1+qTargetscore2+qTargetscore3+qTargetscore4+
                qTargetscore5+qTargetscore6+qTargetscore7+qTargetscore8+
                qTargetscore9+qTargetscore10+qTargetscore11+qTargetscore12+
                qTargetscore13+qTargetscore14+qTargetscore15+qTargetscore16+
                qTargetscore17+qTargetscore18+qTargetscore19+qTargetscore20+
                qTargetscore21+qTargetscore22+qTargetscore23+qTargetscore24+
                qTargetscore25;

        if(totalScore>30){
            totalScore = 30;
        }

        /**下面是动态的：后续可能需要改造**/
        double weekSum = totalScore;
        String finalSum = String.format("%.2f",weekSum);

        return finalSum;
    }

    /**出勤考核总分*/
    public static String scoreCalculationCqkh(String score,String score1) {
        /**下面是动态的：后续可能需要改造**/
        double cqkhSum = Double.parseDouble(score)+Double.parseDouble(score1);
        String finalSum = String.format("%.2f",cqkhSum);
        return finalSum;
    }

    /**加分项总分*/
    public static String scoreCalculationJfx(int score) {
        /**下面是动态的：后续可能需要改造**/
        double weekSum = score;
        String finalSum = String.format("%.2f",weekSum);
        return finalSum;
    }



}
